<?php

use Phinx\Migration\AbstractMigration;
use Phinx\Db\Adapter\MysqlAdapter;
class Camps extends AbstractMigration
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
     public function up()
    {
        $table = $this->table('camps', array('comment' => '营地表'));
        $table
              ->addColumn('name', 'string', array('limit' => 255, 'comment' => '营地名称')) //营地名称
              ->addColumn('number', 'string', array('limit' => 255, 'comment' => '营地编号')) //营地编号
              ->addColumn('type', 'integer', array('limit' => MysqlAdapter::INT_REGULAR,'comment' => '营地类型')) //营地类型
              ->addColumn('grade', 'integer', array('limit' => MysqlAdapter::INT_REGULAR,'comment' => '营地星级')) //营地星级
              ->addColumn('tel', 'string', array('limit' => 255, 'comment' => '营地联系方式')) //营地联系方式
              ->addColumn('branch_name', 'string', array('limit' => 255, 'comment' => '营地所属分公司')) //营地所属分公司名称
              ->addColumn('branch_id', 'string', array('limit' => 255, 'comment' => '营地所属分公司')) //营地所属分公司id
              ->addColumn('email', 'string', array('limit' => 255, 'comment' => '邮件')) //邮件
              ->addColumn('travel_money_base', 'string', array('limit' => 255, 'comment' => '旅行币基数')) //旅行币基数
              ->addColumn('rent_money_base', 'string', array('limit' => 255, 'comment' => '营地单日出租基数','default'=>'')) 
              ->addColumn('credit_code', 'string', array('limit' => 255, 'comment' => '统一社会信用代码')) //统一社会信用代码
              ->addColumn('legal_person', 'string', array('limit' => 255, 'comment' => '法人代表')) //法人代表
              ->addColumn('count', 'integer', array('limit' => MysqlAdapter::INT_REGULAR, 'comment' => '营地泊位数量')) //营地的泊位数量
              ->addColumn('profiles', 'string', array('limit' => 255, 'null' => true, 'comment' => '营地描述')) //营地描述
              ->addColumn('cover', 'string', array('limit' => 255, 'null' => true, 'comment' => '营地封面')) //营地封面
              ->addColumn('content', 'text', array('null' => true, 'comment' => '营地的内容')) //关于营地的内容
              ->addColumn('license', 'string', array('limit' => 255, 'null' => true, 'comment' => '营业执照')) //营业执照
              ->addColumn('country', 'integer', array('limit' => MysqlAdapter::INT_REGULAR,'comment' => '营地所属国家')) 
              ->addColumn('province', 'integer', array('limit' => MysqlAdapter::INT_REGULAR,'comment' => '营地所属省份')) 
              ->addColumn('city', 'integer', array('limit' => MysqlAdapter::INT_REGULAR,'comment' => '营地所属城市')) 
              ->addColumn('area', 'integer', array('limit' => MysqlAdapter::INT_REGULAR,'comment' => '营地所属地区'))
              ->addColumn('address', 'string', array('limit' => 255, 'comment' => '营地详细地址')) //营地地址
              ->addColumn('lat', 'float', array('null' => true, 'comment' => '营地的纬度')) //营地的纬度
              ->addColumn('lng', 'float', array('null' => true, 'comment' => '营地的经度')) //营地的经度
              ->addColumn('status', 'integer', array('default' => -99, 'limit' => MysqlAdapter::INT_TINY, 'comment' => '状态'))
              ->addColumn('campmanager_phone', 'integer', array('limit' => MysqlAdapter::INT_TINY, 'comment' => '超级管理员手机号')) 
              ->addColumn('campmanager_name', 'string', array('limit' => 255, 'comment' => '超级管理员姓名')) 
              ->addColumn('created_at', 'timestamp', array('default' => 'CURRENT_TIMESTAMP', 'comment' => '该条数据创建时间'))
              ->addColumn('updated_at', 'timestamp', array('null' => true, 'comment' => '该条数据修改时间'))
      			  ->addColumn('deleted_at', 'timestamp', array('null' => true))
      			  ->addIndex('number', array('name'=>'camps_cn_number_index'))
              ->addIndex('id')
              ->save();   
    }
    public function down()
    {
        $this->dropTable('camps');
    }
}
